create trigger [dbo].[delete_aspnet_user]
on [dbo].[aspnet_Users]
instead of delete
as
begin try
	begin tran
		DECLARE @UserId uniqueidentifier
		SET @UserId = (select top 1 userid from deleted);
	   
	   DELETE FROM aspnet_Profile WHERE UserID = @UserId
	   DELETE FROM aspnet_UsersInRoles WHERE UserID = @UserId
	   DELETE FROM aspnet_PersonalizationPerUser WHERE UserID = @UserId
	   DELETE FROM dbo.aspnet_Membership WHERE UserID = @UserId
	   DELETE FROM aspnet_users WHERE UserID = @UserId
	   
	   DELETE FROM Friend WHERE RequestFromID = @UserId OR RequestToID = @UserId
	   DELETE FROM [Message] WHERE FromID = @UserId OR ToID = @UserId
	   DELETE FROM UserInterest WHERE UserID = @UserId
	   DELETE FROM Wall WHERE FromID = @UserId OR ToID = @UserId
	   
	commit tran
end try
begin catch
	rollback tran;
end catch;
